Describe int, double, and boolean

Three of the most important variables to know are integers, doubles, and booleans.
- Integers (int) are whole numbers without decimals ( ex: 1, 2, 3, 125)
- Doubles are numbers that include a decimal ( ex: 1.0, 2.9, 73.576)
- Boolean has two choices, True or False; operations and, or, not.

Primitive types - as distinct from composite types - are data types provided by a programming language as basic building blocks. Primitive types are also known as built-in types or basic types.

How do you create them?

In a program, variables can be created directly or indirectly.

-When you create a variable directly, this means that you give the variable a value when it is created. This is useful when you want the variable to keep the same value throughout the program.
Integers: int x = 5;
Doubles: double y = 2.5;
Boolean: boolean z = true;

-When you create a variable indirectly, you create a variable but don't set a certain value for it. This way, you can change the value in the code. This is useful if you have a variable that changes.
Integers: int x;
x = 5;
Doubles: double y;
y = 6.45;
Boolean: boolean z;
z = false;

How can you use them?

At times, changing an integer into a double is necessary to prevent inaccuracy in data. A good example of this is when an integer (7) is divided by another number (4). The answer to this outside of the java language should be 1.75. However, the answer given would be 1 because the computer eliminates everything to the right of the decimal place. The way to limit this appalling inaccuracy is by casting.
Casting can look like:
(double) 8 / 3; makes 8 a double so that the answer is a double
8.0 / 3;
makes 8 a double instead of an integer by putting a decimal in it
8 / 3.0; makes 3 a double instead of an integer so the return is also a double

Limitations
The severe limitations with primitive types are their inability to be used in ArrayLists and facilitate methods because they do not have a class. For example, you cannot use a ,compareTo() method with int variables. Methods such as these make your code more efficient and are extremely useful to facilitate your own methods. This can be overcome by the use of wrapper classes.


Anything else important?